package day05;
import java.util.Scanner;
import java.util.Arrays;
public class Exercise01 {
    public static void main(String[] args) {
        /*
        //1. Addition随机加法运算器
        //要求：由系统随机出10道加法题，而后由用户来答题，答题后输出"答对了"或"答错了"，答对1题得10分，答错1题不扣分，最后输出总分数。
        Scanner sc = new Scanner(System.in);
        int score = 0;
        for (int i =1;i<11;i++) {
            int a = (int)(Math.random()*100);
            int b = (int)(Math.random()*100);
            int result = a+b;
            System.out.println("(" + i + "):" + a + "+" + b + "=？");
            int answer = sc.nextInt();
            if (answer==result) {
                System.out.println("恭喜你答对了！");
                score+=10;
            } else {
                System.out.println("答错了");
            }
        }
        System.out.println("最终的成绩为:"+score);

         */


        /*//2. MultiTable九九乘法表
        //   要求：输出九九乘法表
        for (int i = 1; i <= 9; i++) {
            for (int j = 1; j <=i ; j++) {
                System.out.print(j+"*"+i+"="+j*i+"\t");
            }
            System.out.println();
        }

         */


        /*//3. 数组小代码练习：声明、初始化、访问、遍历
        int[] arri = new int[3];
        double[] arrd = new double[5];
        boolean[] arrb = new boolean[12];

        int[] arr1 = new  int[5];
        int[] arr2 = {1,2,3};
        int[] arr3 = new  int[]{1,3,5,7,9};
        int[] arr4;
        arr4 = new int[]{2,4,6,8,10};

        int[] arr = new int[3];
        System.out.println(arr.length);//输出数组的长度
        arr[0] = 2;
        arr[1] = 4;
        arr[2] = 6;
        System.out.println(arr[arr.length-1]);//输出数组最后一个元素值
        //System.out.println(arr[arr.length]);//数组操作异常，下标越界

        int [] arr10 = new int[10];//遍历数组
        for (int i = 0; i <arr10.length ; i++) {
            arr10[i]= (int)(Math.random()*100);
            System.out.println(arr10[i]);
        }

         */



        /*//4. MaxOfArray求数组元素最大值
        int[] arr = new int[10];
        for (int i = 0; i < arr.length ; i++) {
            arr[i] = (int)(Math.random()*100);
            System.out.println(arr[i]);
        }
        int max = arr[0];
        for (int i = 1; i <arr.length ; i++) {
            if (max<arr[i]){
                max = arr[i];
            }
        }
        System.out.println("最大值为:"+max);

         */


        /*//5. 对数组进行升序排列，并输出排序后的结果
        int[] arr = new int[10];
        for (int i = 0; i < arr.length ; i++) {
            arr[i] = (int)(Math.random()*100);
            System.out.println(arr[i]);
        }
        Arrays.sort(arr);
        System.out.println("从小到大排序为:");
        for (int i = 0; i < arr.length; i++) {//从小到大
            System.out.println(arr[i]);
        }
        System.out.println("从大到小排序为:");
        for (int i = arr.length-1; i >= 0; i--) {//从大到小
            System.out.println(arr[i]);
        }

         */
    }
}
